package com.heima.admin.controller.v1;

import com.heima.admin.service.AdSensitiveService;
import com.heima.api.admin.AdSensitiveControllerApi;
import com.heima.model.admin.dtos.SensitiveDto;
import com.heima.model.admin.pojos.AdSensitive;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/sensitive")
public class AdSensitiveController implements AdSensitiveControllerApi {

    @Autowired
    AdSensitiveService adSensitiveService;


    /**
     * 根据id删除
     *
     * @param id
     * @return
     */
    @Override
    @DeleteMapping("/del/{id}")
    public ResponseResult delete(@PathVariable("id") Integer id) {
        return adSensitiveService.delete(id);
    }

    /**
     * 修改
     *
     * @param adSensitive
     * @return
     */
    @Override
    @PutMapping("/update")
    public ResponseResult update(@RequestBody AdSensitive adSensitive) {
        return adSensitiveService.update(adSensitive);
    }

    /**
     * 新增
     *
     * @param adSensitive
     * @return
     */
    @Override
    @PostMapping("/save")
    public ResponseResult insert(@RequestBody AdSensitive adSensitive) {
        return adSensitiveService.insert(adSensitive);
    }

    /**
     * 敏感词的分页按照关键字模糊查询
     *
     * @param sensitiveDto
     * @return
     */
    @Override
    @PostMapping("/list")
    public ResponseResult findNameByPage(@RequestBody SensitiveDto sensitiveDto) {
        return adSensitiveService.findNameByPage(sensitiveDto);
    }
}
